home *** CD-ROM | disk | FTP | other *** search
/ Delphi Anthology / aDELPHI.iso / Runimage / Delphi50 / Source / Decision Cube / mxdsql.pas < prev    next >
Pascal/Delphi Source File  |  1999-08-11  |  2KB  |  68 lines

  1. {*******************************************************}
  2. {                                                       }
  3. {       Borland Delphi Visual Component Library         }
  4. {                                                       }
  5. {       Copyright (c) 1997,99 Inprise Corporation       }
  6. {                                                       }
  7. {*******************************************************}
  8.  
  9. unit mxdsql;
  10.  
  11. interface
  12.  
  13. uses
  14.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  15.   Db, DBTables, Grids, DBGrids, StdCtrls;
  16.  
  17. type
  18.   TSQLWindow = class(TForm)
  19.     DBGrid1: TDBGrid;
  20.     Query1: TQuery;
  21.     DataSource1: TDataSource;
  22.     Memo1: TMemo;
  23.   private
  24.     { Private declarations }
  25.   public
  26.     function SInitialize(DataBaseName: string; SQL: string): Boolean;
  27.     { Public declarations }
  28.   end;
  29.  
  30. var
  31.   Form2: TSQLWindow;
  32.  
  33. procedure ShowSQLWindow(DataBaseName: string; SQL: string);
  34.  
  35. implementation
  36.  
  37. {$R *.DFM}
  38.  
  39. procedure ShowSQLWindow(DataBaseName: string; SQL: string);
  40. var
  41.   aWindow: TSQLWindow;
  42.   x,y: Integer;
  43. begin
  44.   aWindow := TSQLWindow.Create(application);
  45.   if (aWindow.SInitialize(DataBaseName, SQL)) then
  46.   begin
  47.     x := (Screen.Width - aWindow.Width) div 2;
  48.     y := (Screen.Height - aWindow.Height) div 2;
  49.     if (x < 0) then x := 0;
  50.     if (y < 0) then y := 0;
  51.     aWindow.Left := x;
  52.     aWindow.Top := y;
  53.     aWindow.ShowModal;
  54.   end;
  55.   aWindow.free;
  56. end;
  57.  
  58. function TSQLWindow.SInitialize(DataBaseName: string; SQL: string): Boolean;
  59. begin
  60.   Query1.DataBaseName := DataBaseName;
  61.   Query1.SQL.text := SQL;
  62.   Query1.active := True;
  63.   Memo1.text := SQL;
  64.   Result := Query1.active;
  65. end;
  66.  
  67. end.
  68.